var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
// 1. 基本数据类型
var username = "张三";
var age = 25;
var isStudent = true;
var hobbies = ["读书", "运动"];
var favoriteNumber = "7";
// 4. 对象类型
var user = {
    name: username,
    age: age,
    isStudent: isStudent
};
var product = {
    id: 101,
    name: "TypeScript入门书",
    price: 59.9
};
// 5. 使用交叉类型
var userWithProduct = __assign(__assign({}, user), { product: product });
// 页面加载后执行
window.onload = function () {
    // 获取DOM元素（可能为null，需要类型判断）
    var userInfoDiv = document.getElementById('userInfo');
    var productInfoDiv = document.getElementById('productInfo');
    var messageDiv = document.getElementById('message');
    // 类型守卫：确保元素存在
    if (userInfoDiv instanceof HTMLElement) {
        userInfoDiv.innerHTML = "\n            <h3>\u7528\u6237\u4FE1\u606F</h3>\n            <p>\u59D3\u540D: ".concat(user.name, "</p>\n            <p>\u5E74\u9F84: ").concat(user.age, "</p>\n            <p>\u662F\u5426\u5B66\u751F: ").concat(user.isStudent ? '是' : '否', "</p>\n        ");
        userInfoDiv.style.color = 'darkblue';
    }
    if (productInfoDiv instanceof HTMLElement) {
        productInfoDiv.innerHTML = "\n            <h3>\u4EA7\u54C1\u4FE1\u606F</h3>\n            <p>ID: ".concat(product.id, "</p>\n            <p>\u540D\u79F0: ").concat(product.name, "</p>\n            <p>\u4EF7\u683C: \u00A5").concat(product.price, "</p>\n        ");
        productInfoDiv.style.color = 'darkgreen';
    }
    // 联合类型使用示例
    if (messageDiv instanceof HTMLElement) {
        var message = void 0;
        // 类型判断（联合类型的类型守卫）
        if (typeof favoriteNumber === 'string') {
            message = "\u6700\u559C\u6B22\u7684\u6570\u5B57\u662F\u5B57\u7B26\u4E32\u5F62\u5F0F: ".concat(favoriteNumber);
        }
        else {
            message = "\u6700\u559C\u6B22\u7684\u6570\u5B57\u662F\u6570\u5B57\u5F62\u5F0F: ".concat(favoriteNumber);
        }
        messageDiv.textContent = message;
        messageDiv.style.fontWeight = 'bold';
    }
};
